// BasicProperty.cpp: implementation of the BasicProperty class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "BasicProperty.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

BasicProperty::BasicProperty()
{

}

BasicProperty::~BasicProperty()
{

}

double BasicProperty::GetValue()
{
	double dbValue = 0.0;
	int iProRsID = 0;
	CString strSql;
	iProRsID = GetProRsID();
	if( iProRsID == 0)
	{
		return 0;
	}

	_RecordsetPtr pRs;
	strSql.Format( _T("SELECT * FROM Material WHERE ID = %d"),iProRsID);
	
	try
	{
		pRs.CreateInstance(__uuidof(Recordset));
		pRs->Open(_variant_t(strSql),(IDispatch *)m_pCon,adOpenStatic,adLockOptimistic,adCmdText);
		if( !(pRs->adoEOF && pRs->BOF) )
		{
			dbValue = vtof( pRs->GetCollect(_variant_t( GetDataFieldName() )) ) ;
		}
	}
	catch( _com_error &e )
	{
		AfxMessageBox(e.Description());
	}
	return dbValue;
}


